.class public Lcom/noshufou/android/su/widget/LogAdapter;
.super Landroid/support/v4/widget/CursorAdapter;
.source "LogAdapter.java"

# interfaces
.implements Landroid/widget/AbsListView$OnScrollListener;
.implements Landroid/widget/SectionIndexer;
.implements Lcom/noshufou/android/su/widget/PinnedHeaderListView$PinnedHeaderAdapter;


# static fields
.field private static final LOG_COLUMN_DATE:I = 0x2

.field private static final LOG_COLUMN_NAME:I = 0x1

.field private static final LOG_COLUMN_TYPE:I = 0x3

.field public static final PROJECTION:[Ljava/lang/String;


# instance fields
.field private mContext:Landroid/content/Context;

.field private mCursor:Landroid/database/Cursor;

.field private mDisplaySectionHeaders:Z

.field private mIndexer:Landroid/widget/SectionIndexer;

.field private mShowName:Z


# direct methods
.method static constructor <clinit>()V
    .locals 3

    .prologue
    .line 29
    const/4 v0, 0x4

    new-array v0, v0, [Ljava/lang/String;

    const/4 v1, 0x0

    .line 30
    const-string v2, "_id"

    aput-object v2, v0, v1

    const/4 v1, 0x1

    const-string v2, "name"

    aput-object v2, v0, v1

    const/4 v1, 0x2

    const-string v2, "date"

    aput-object v2, v0, v1

    const/4 v1, 0x3

    const-string v2, "type"

    aput-object v2, v0, v1

    .line 29
    sput-object v0, Lcom/noshufou/android/su/widget/LogAdapter;->PROJECTION:[Ljava/lang/String;

    .line 19
    return-void
.end method

.method public constructor <init>(Landroid/database/Cursor;Landroid/content/Context;)V
    .locals 2
    .parameter "cursor"
    .parameter "context"

    .prologue
    const/4 v1, 0x1

    .line 38
    const/4 v0, 0x0

    invoke-direct {p0, p2, p1, v0}, Landroid/support/v4/widget/CursorAdapter;-><init>(Landroid/content/Context;Landroid/database/Cursor;Z)V

    .line 24
    iput-boolean v1, p0, Lcom/noshufou/android/su/widget/LogAdapter;->mDisplaySectionHeaders:Z

    .line 25
    iput-boolean v1, p0, Lcom/noshufou/android/su/widget/LogAdapter;->mShowName:Z

    .line 39
    iput-object p1, p0, Lcom/noshufou/android/su/widget/LogAdapter;->mCursor:Landroid/database/Cursor;

    .line 40
    iput-object p2, p0, Lcom/noshufou/android/su/widget/LogAdapter;->mContext:Landroid/content/Context;

    .line 41
    return-void
.end method

.method public constructor <init>(Landroid/database/Cursor;Landroid/content/Context;Z)V
    .locals 0
    .parameter "cursor"
    .parameter "context"
    .parameter "showName"

    .prologue
    .line 44
    invoke-direct {p0, p1, p2}, Lcom/noshufou/android/su/widget/LogAdapter;-><init>(Landroid/database/Cursor;Landroid/content/Context;)V

    .line 45
    iput-boolean p3, p0, Lcom/noshufou/android/su/widget/LogAdapter;->mShowName:Z

    .line 46
    return-void
.end method

.method private bindSectionHeader(Landroid/view/View;IZ)V
    .locals 7
    .parameter "itemView"
    .parameter "position"
    .parameter "displaySectionHeaders"

    .prologue
    const/4 v6, 0x0

    const/4 v5, 0x1

    const/4 v4, 0x0

    .line 113
    move-object v2, p1

    check-cast v2, Lcom/noshufou/android/su/widget/LogListItem;

    .line 114
    .local v2, view:Lcom/noshufou/android/su/widget/LogListItem;
    if-nez p3, :cond_0

    .line 115
    invoke-virtual {v2, v6}, Lcom/noshufou/android/su/widget/LogListItem;->setSectionHeader(Ljava/lang/String;)V

    .line 116
    invoke-virtual {v2, v5}, Lcom/noshufou/android/su/widget/LogListItem;->setDividerVisible(Z)V

    .line 134
    :goto_0
    return-void

    .line 118
    :cond_0
    invoke-virtual {p0, p2}, Lcom/noshufou/android/su/widget/LogAdapter;->getSectionForPosition(I)I

    move-result v0

    .line 119
    .local v0, section:I
    invoke-virtual {p0, v0}, Lcom/noshufou/android/su/widget/LogAdapter;->getPositionForSection(I)I

    move-result v3

    if-ne v3, p2, :cond_1

    .line 120
    iget-object v3, p0, Lcom/noshufou/android/su/widget/LogAdapter;->mIndexer:Landroid/widget/SectionIndexer;

    invoke-interface {v3}, Landroid/widget/SectionIndexer;->getSections()[Ljava/lang/Object;

    move-result-object v3

    aget-object v1, v3, v0

    check-cast v1, Ljava/lang/String;

    .line 121
    .local v1, title:Ljava/lang/String;
    invoke-virtual {v2, v1}, Lcom/noshufou/android/su/widget/LogListItem;->setSectionHeader(Ljava/lang/String;)V

    .line 128
    .end local v1           #title:Ljava/lang/String;
    :goto_1
    add-int/lit8 v3, v0, 0x1

    invoke-virtual {p0, v3}, Lcom/noshufou/android/su/widget/LogAdapter;->getPositionForSection(I)I

    move-result v3

    add-int/lit8 v3, v3, -0x1

    if-ne v3, p2, :cond_2

    .line 129
    invoke-virtual {v2, v4}, Lcom/noshufou/android/su/widget/LogListItem;->setDividerVisible(Z)V

    goto :goto_0

    .line 123
    :cond_1
    invoke-virtual {v2, v4}, Lcom/noshufou/android/su/widget/LogListItem;->setDividerVisible(Z)V

    .line 124
    invoke-virtual {v2, v6}, Lcom/noshufou/android/su/widget/LogListItem;->setSectionHeader(Ljava/lang/String;)V

    goto :goto_1

    .line 131
    :cond_2
    invoke-virtual {v2, v5}, Lcom/noshufou/android/su/widget/LogListItem;->setDividerVisible(Z)V

    goto :goto_0
.end method

.method private updateIndexer(Landroid/database/Cursor;)V
    .locals 3
    .parameter "cursor"

    .prologue
    .line 56
    if-eqz p1, :cond_0

    invoke-interface {p1}, Landroid/database/Cursor;->getCount()I

    move-result v0

    if-nez v0, :cond_1

    .line 57
    :cond_0
    const/4 v0, 0x0

    iput-object v0, p0, Lcom/noshufou/android/su/widget/LogAdapter;->mIndexer:Landroid/widget/SectionIndexer;

    .line 62
    :goto_0
    return-void

    .line 61
    :cond_1
    new-instance v0, Lcom/noshufou/android/su/widget/DateIndexer;

    iget-object v1, p0, Lcom/noshufou/android/su/widget/LogAdapter;->mContext:Landroid/content/Context;

    const/4 v2, 0x2

    invoke-direct {v0, v1, p1, v2}, Lcom/noshufou/android/su/widget/DateIndexer;-><init>(Landroid/content/Context;Landroid/database/Cursor;I)V

    iput-object v0, p0, Lcom/noshufou/android/su/widget/LogAdapter;->mIndexer:Landroid/widget/SectionIndexer;

    goto :goto_0
.end method


# virtual methods
.method public bindView(Landroid/view/View;Landroid/content/Context;Landroid/database/Cursor;)V
    .locals 4
    .parameter "view"
    .parameter "context"
    .parameter "cursor"

    .prologue
    .line 88
    move-object v0, p1

    check-cast v0, Lcom/noshufou/android/su/widget/LogListItem;

    .line 90
    .local v0, item:Lcom/noshufou/android/su/widget/LogListItem;
    const/4 v2, 0x2

    invoke-interface {p3, v2}, Landroid/database/Cursor;->getLong(I)J

    move-result-wide v2

    .line 89
    invoke-static {p2, v2, v3}, Lcom/noshufou/android/su/util/Util;->formatTime(Landroid/content/Context;J)Ljava/lang/String;

    move-result-object v2

    invoke-virtual {v0, v2}, Lcom/noshufou/android/su/widget/LogListItem;->setTimeText(Ljava/lang/CharSequence;)V

    .line 91
    iget-boolean v2, p0, Lcom/noshufou/android/su/widget/LogAdapter;->mShowName:Z

    if-eqz v2, :cond_0

    .line 92
    const/4 v2, 0x1

    invoke-interface {p3, v2}, Landroid/database/Cursor;->getString(I)Ljava/lang/String;

    move-result-object v2

    invoke-virtual {v0, v2}, Lcom/noshufou/android/su/widget/LogListItem;->setNameText(Ljava/lang/CharSequence;)V

    .line 94
    :cond_0
    const v1, 0x7f0b0020

    .line 95
    .local v1, logType:I
    const/4 v2, 0x3

    invoke-interface {p3, v2}, Landroid/database/Cursor;->getInt(I)I

    move-result v2

    packed-switch v2, :pswitch_data_0

    .line 109
    :goto_0
    iget-object v2, p0, Lcom/noshufou/android/su/widget/LogAdapter;->mContext:Landroid/content/Context;

    invoke-virtual {v2, v1}, Landroid/content/Context;->getString(I)Ljava/lang/String;

    move-result-object v2

    invoke-virtual {v0, v2}, Lcom/noshufou/android/su/widget/LogListItem;->setTypeText(Ljava/lang/CharSequence;)V

    .line 110
    return-void

    .line 97
    :pswitch_0
    const v1, 0x7f0b0021

    .line 98
    goto :goto_0

    .line 100
    :pswitch_1
    const v1, 0x7f0b0022

    .line 101
    goto :goto_0

    .line 103
    :pswitch_2
    const v1, 0x7f0b0023

    .line 104
    goto :goto_0

    .line 106
    :pswitch_3
    const v1, 0x7f0b0024

    goto :goto_0

    .line 95
    :pswitch_data_0
    .packed-switch 0x0
        :pswitch_1
        :pswitch_0
        :pswitch_2
        :pswitch_3
    .end packed-switch
.end method

.method public configurePinnedHeader(Landroid/view/View;II)V
    .locals 8
    .parameter "header"
    .parameter "position"
    .parameter "alpha"

    .prologue
    .line 198
    invoke-virtual {p1}, Landroid/view/View;->getTag()Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Lcom/noshufou/android/su/widget/PinnedHeaderListView$PinnedHeaderCache;

    .line 199
    .local v0, cache:Lcom/noshufou/android/su/widget/PinnedHeaderListView$PinnedHeaderCache;
    if-nez v0, :cond_0

    .line 200
    new-instance v0, Lcom/noshufou/android/su/widget/PinnedHeaderListView$PinnedHeaderCache;

    .end local v0           #cache:Lcom/noshufou/android/su/widget/PinnedHeaderListView$PinnedHeaderCache;
    invoke-direct {v0}, Lcom/noshufou/android/su/widget/PinnedHeaderListView$PinnedHeaderCache;-><init>()V

    .line 201
    .restart local v0       #cache:Lcom/noshufou/android/su/widget/PinnedHeaderListView$PinnedHeaderCache;
    const v4, 0x7f0a0037

    invoke-virtual {p1, v4}, Landroid/view/View;->findViewById(I)Landroid/view/View;

    move-result-object v4

    check-cast v4, Landroid/widget/TextView;

    iput-object v4, v0, Lcom/noshufou/android/su/widget/PinnedHeaderListView$PinnedHeaderCache;->titleView:Landroid/widget/TextView;

    .line 202
    iget-object v4, v0, Lcom/noshufou/android/su/widget/PinnedHeaderListView$PinnedHeaderCache;->titleView:Landroid/widget/TextView;

    invoke-virtual {v4}, Landroid/widget/TextView;->getTextColors()Landroid/content/res/ColorStateList;

    move-result-object v4

    iput-object v4, v0, Lcom/noshufou/android/su/widget/PinnedHeaderListView$PinnedHeaderCache;->textColor:Landroid/content/res/ColorStateList;

    .line 203
    invoke-virtual {p1}, Landroid/view/View;->getBackground()Landroid/graphics/drawable/Drawable;

    move-result-object v4

    iput-object v4, v0, Lcom/noshufou/android/su/widget/PinnedHeaderListView$PinnedHeaderCache;->background:Landroid/graphics/drawable/Drawable;

    .line 204
    invoke-virtual {p1, v0}, Landroid/view/View;->setTag(Ljava/lang/Object;)V

    .line 207
    :cond_0
    invoke-virtual {p0, p2}, Lcom/noshufou/android/su/widget/LogAdapter;->getSectionForPosition(I)I

    move-result v1

    .line 209
    .local v1, section:I
    iget-object v4, p0, Lcom/noshufou/android/su/widget/LogAdapter;->mIndexer:Landroid/widget/SectionIndexer;

    invoke-interface {v4}, Landroid/widget/SectionIndexer;->getSections()[Ljava/lang/Object;

    move-result-object v4

    aget-object v3, v4, v1

    check-cast v3, Ljava/lang/String;

    .line 210
    .local v3, title:Ljava/lang/String;
    iget-object v4, v0, Lcom/noshufou/android/su/widget/PinnedHeaderListView$PinnedHeaderCache;->titleView:Landroid/widget/TextView;

    invoke-virtual {v4, v3}, Landroid/widget/TextView;->setText(Ljava/lang/CharSequence;)V

    .line 212
    const/16 v4, 0xff

    if-ne p3, v4, :cond_1

    .line 214
    iget-object v4, v0, Lcom/noshufou/android/su/widget/PinnedHeaderListView$PinnedHeaderCache;->background:Landroid/graphics/drawable/Drawable;

    invoke-virtual {p1, v4}, Landroid/view/View;->setBackgroundDrawable(Landroid/graphics/drawable/Drawable;)V

    .line 215
    iget-object v4, v0, Lcom/noshufou/android/su/widget/PinnedHeaderListView$PinnedHeaderCache;->titleView:Landroid/widget/TextView;

    iget-object v5, v0, Lcom/noshufou/android/su/widget/PinnedHeaderListView$PinnedHeaderCache;->textColor:Landroid/content/res/ColorStateList;

    invoke-virtual {v4, v5}, Landroid/widget/TextView;->setTextColor(Landroid/content/res/ColorStateList;)V

    .line 226
    :goto_0
    return-void

    .line 220
    :cond_1
    const v4, 0xffffff

    invoke-virtual {p1, v4}, Landroid/view/View;->setBackgroundColor(I)V

    .line 222
    iget-object v4, v0, Lcom/noshufou/android/su/widget/PinnedHeaderListView$PinnedHeaderCache;->textColor:Landroid/content/res/ColorStateList;

    invoke-virtual {v4}, Landroid/content/res/ColorStateList;->getDefaultColor()I

    move-result v2

    .line 223
    .local v2, textColor:I
    iget-object v4, v0, Lcom/noshufou/android/su/widget/PinnedHeaderListView$PinnedHeaderCache;->titleView:Landroid/widget/TextView;

    .line 224
    invoke-static {v2}, Landroid/graphics/Color;->red(I)I

    move-result v5

    invoke-static {v2}, Landroid/graphics/Color;->green(I)I

    move-result v6

    invoke-static {v2}, Landroid/graphics/Color;->blue(I)I

    move-result v7

    .line 223
    invoke-static {p3, v5, v6, v7}, Landroid/graphics/Color;->argb(IIII)I

    move-result v5

    invoke-virtual {v4, v5}, Landroid/widget/TextView;->setTextColor(I)V

    goto :goto_0
.end method

.method public getDisplaySectionHeadersEnabled()Z
    .locals 1

    .prologue
    .line 65
    iget-boolean v0, p0, Lcom/noshufou/android/su/widget/LogAdapter;->mDisplaySectionHeaders:Z

    return v0
.end method

.method public getPinnedHeaderState(I)I
    .locals 4
    .parameter "position"

    .prologue
    const/4 v2, 0x0

    .line 178
    iget-object v3, p0, Lcom/noshufou/android/su/widget/LogAdapter;->mIndexer:Landroid/widget/SectionIndexer;

    if-eqz v3, :cond_0

    iget-object v3, p0, Lcom/noshufou/android/su/widget/LogAdapter;->mCursor:Landroid/database/Cursor;

    if-eqz v3, :cond_0

    iget-object v3, p0, Lcom/noshufou/android/su/widget/LogAdapter;->mCursor:Landroid/database/Cursor;

    invoke-interface {v3}, Landroid/database/Cursor;->getCount()I

    move-result v3

    if-eqz v3, :cond_0

    .line 179
    iget-object v3, p0, Lcom/noshufou/android/su/widget/LogAdapter;->mCursor:Landroid/database/Cursor;

    invoke-interface {v3}, Landroid/database/Cursor;->isClosed()Z

    move-result v3

    if-eqz v3, :cond_1

    .line 193
    :cond_0
    :goto_0
    return v2

    .line 183
    :cond_1
    if-ltz p1, :cond_0

    .line 187
    invoke-virtual {p0, p1}, Lcom/noshufou/android/su/widget/LogAdapter;->getSectionForPosition(I)I

    move-result v1

    .line 188
    .local v1, section:I
    add-int/lit8 v2, v1, 0x1

    invoke-virtual {p0, v2}, Lcom/noshufou/android/su/widget/LogAdapter;->getPositionForSection(I)I

    move-result v0

    .line 189
    .local v0, nextSectionPosition:I
    const/4 v2, -0x1

    if-eq v0, v2, :cond_2

    add-int/lit8 v2, v0, -0x1

    if-ne p1, v2, :cond_2

    .line 190
    const/4 v2, 0x2

    goto :goto_0

    .line 193
    :cond_2
    const/4 v2, 0x1

    goto :goto_0
.end method

.method public getPositionForSection(I)I
    .locals 1
    .parameter "section"

    .prologue
    .line 147
    iget-object v0, p0, Lcom/noshufou/android/su/widget/LogAdapter;->mIndexer:Landroid/widget/SectionIndexer;

    if-nez v0, :cond_0

    .line 148
    const/4 v0, -0x1

    .line 150
    :goto_0
    return v0

    :cond_0
    iget-object v0, p0, Lcom/noshufou/android/su/widget/LogAdapter;->mIndexer:Landroid/widget/SectionIndexer;

    invoke-interface {v0, p1}, Landroid/widget/SectionIndexer;->getPositionForSection(I)I

    move-result v0

    goto :goto_0
.end method

.method public getSectionForPosition(I)I
    .locals 1
    .parameter "position"

    .prologue
    .line 156
    iget-object v0, p0, Lcom/noshufou/android/su/widget/LogAdapter;->mIndexer:Landroid/widget/SectionIndexer;

    if-nez v0, :cond_0

    .line 157
    const/4 v0, -0x1

    .line 159
    :goto_0
    return v0

    :cond_0
    iget-object v0, p0, Lcom/noshufou/android/su/widget/LogAdapter;->mIndexer:Landroid/widget/SectionIndexer;

    invoke-interface {v0, p1}, Landroid/widget/SectionIndexer;->getSectionForPosition(I)I

    move-result v0

    goto :goto_0
.end method

.method public getSections()[Ljava/lang/Object;
    .locals 3

    .prologue
    .line 138
    iget-object v0, p0, Lcom/noshufou/android/su/widget/LogAdapter;->mIndexer:Landroid/widget/SectionIndexer;

    if-nez v0, :cond_0

    .line 139
    const/4 v0, 0x1

    new-array v0, v0, [Ljava/lang/String;

    const/4 v1, 0x0

    const-string v2, " "

    aput-object v2, v0, v1

    .line 141
    :goto_0
    return-object v0

    :cond_0
    iget-object v0, p0, Lcom/noshufou/android/su/widget/LogAdapter;->mIndexer:Landroid/widget/SectionIndexer;

    invoke-interface {v0}, Landroid/widget/SectionIndexer;->getSections()[Ljava/lang/Object;

    move-result-object v0

    goto :goto_0
.end method

.method public getView(ILandroid/view/View;Landroid/view/ViewGroup;)Landroid/view/View;
    .locals 2
    .parameter "position"
    .parameter "convertView"
    .parameter "parent"

    .prologue
    .line 75
    invoke-super {p0, p1, p2, p3}, Landroid/support/v4/widget/CursorAdapter;->getView(ILandroid/view/View;Landroid/view/ViewGroup;)Landroid/view/View;

    move-result-object v0

    .line 76
    .local v0, v:Landroid/view/View;
    const/4 v1, 0x1

    invoke-direct {p0, v0, p1, v1}, Lcom/noshufou/android/su/widget/LogAdapter;->bindSectionHeader(Landroid/view/View;IZ)V

    .line 77
    return-object v0
.end method

.method public hasStableIds()Z
    .locals 1

    .prologue
    .line 70
    const/4 v0, 0x1

    return v0
.end method

.method public newView(Landroid/content/Context;Landroid/database/Cursor;Landroid/view/ViewGroup;)Landroid/view/View;
    .locals 2
    .parameter "context"
    .parameter "cursor"
    .parameter "parent"

    .prologue
    .line 82
    new-instance v0, Lcom/noshufou/android/su/widget/LogListItem;

    const/4 v1, 0x0

    invoke-direct {v0, p1, v1}, Lcom/noshufou/android/su/widget/LogListItem;-><init>(Landroid/content/Context;Landroid/util/AttributeSet;)V

    .line 83
    .local v0, view:Lcom/noshufou/android/su/widget/LogListItem;
    return-object v0
.end method

.method public onScroll(Landroid/widget/AbsListView;III)V
    .locals 1
    .parameter "view"
    .parameter "firstVisibleItem"
    .parameter "visibleItemCount"
    .parameter "totalItemCount"

    .prologue
    .line 166
    instance-of v0, p1, Lcom/noshufou/android/su/widget/PinnedHeaderListView;

    if-eqz v0, :cond_0

    .line 167
    check-cast p1, Lcom/noshufou/android/su/widget/PinnedHeaderListView;

    .end local p1
    invoke-virtual {p1, p2}, Lcom/noshufou/android/su/widget/PinnedHeaderListView;->configureHeaderView(I)V

    .line 169
    :cond_0
    return-void
.end method

.method public onScrollStateChanged(Landroid/widget/AbsListView;I)V
    .locals 0
    .parameter "view"
    .parameter "scrollState"

    .prologue
    .line 174
    return-void
.end method

.method public swapCursor(Landroid/database/Cursor;)Landroid/database/Cursor;
    .locals 1
    .parameter "newCursor"

    .prologue
    .line 50
    iput-object p1, p0, Lcom/noshufou/android/su/widget/LogAdapter;->mCursor:Landroid/database/Cursor;

    .line 51
    invoke-direct {p0, p1}, Lcom/noshufou/android/su/widget/LogAdapter;->updateIndexer(Landroid/database/Cursor;)V

    .line 52
    invoke-super {p0, p1}, Landroid/support/v4/widget/CursorAdapter;->swapCursor(Landroid/database/Cursor;)Landroid/database/Cursor;

    move-result-object v0

    return-object v0
.end method
